package com.liuchen.boot;

import com.liuchen.boot.system.BaseApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;

/**
 * 初始化的类
 */
@SpringBootApplication
@EnableScheduling//定时器功能开启
@ComponentScan("com.liuchen")//自动扫描注解
public class Application extends BaseApplication {

    //主方法
    public static void main(String[] args) {
        //显示所用的字符编码,用于测试
        System.out.println("Default Charset=" + Charset.defaultCharset());
        System.out.println("file.encoding=" + System.getProperty("file.encoding"));
        System.out.println("Default Charset=" + Charset.defaultCharset());
        System.out.println("Default Charset in Use=" + getDefaultCharSet());
        //启动spring-boot
        main(Application.class, args);
    }

    /**
     * 获取字符编码
     *
     * @return
     */
    private static String getDefaultCharSet() {
        OutputStreamWriter writer = new OutputStreamWriter(new ByteArrayOutputStream());
        String enc = writer.getEncoding();
        return enc;
    }
}